package org.cainiao.algorithm.temp.niuke;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * <br />
 * <p>
 * Author: Cai Niao(wdhlzd@163.com)<br />
 */
public class HJ18 {

    private static final long ONES = 0XFFFFFFFFL;

    public static void main(String[] args) throws IOException {
        try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int aCount = 0;
            int bCount = 0;
            int cCount = 0;
            int dCount = 0;
            int eCount = 0;
            int errorIpCount = 0;
            int privateIpCount = 0;
            while ((line = bufferedReader.readLine()) != null) {
                String[] ipMask = line.split("~");
                long ipNumber = getNumber(ipMask[0]);
                long maskNumber = getNumber(ipMask[1]);

                long ipNumber1 = ipNumber >> 24;
                if (ipNumber1 == 0 || ipNumber1 == 127) {
                    continue;
                }

                if (ipNumber < 0 || maskNumber <= 0 || maskNumber >= ONES
                    || (((maskNumber ^ ONES) + 1) | maskNumber) != maskNumber) {

                    errorIpCount++;
                    continue;
                }

                if (ipNumber1 >= 1 && ipNumber1 <= 126) {
                    aCount++;
                    if (ipNumber1 == 10) {
                        privateIpCount++;
                    }
                } else if (ipNumber1 >= 128 && ipNumber1 <= 191) {
                    bCount++;
                    if (ipNumber >> 20 == 0XAC1L) {
                        privateIpCount++;
                    }
                } else if (ipNumber1 >= 192 && ipNumber1 <= 223) {
                    cCount++;
                    if (ipNumber >> 16 == 0XC0A8L) {
                        privateIpCount++;
                    }
                } else if (ipNumber1 >= 224 && ipNumber1 <= 239) {
                    dCount++;
                } else if (ipNumber1 >= 240 && ipNumber1 <= 255) {
                    eCount++;
                }
            }
            System.out.printf("%d %d %d %d %d %d %d",
                aCount, bCount, cCount, dCount, eCount, errorIpCount, privateIpCount);
        }
    }

    private static long getNumber(String ipOrMask) {
        char[] ipOrMaskChars = (ipOrMask + ".").toCharArray();
        long number = 0;
        long temp = 0;
        int flag = 0;
        for (char ipOrMaskChar : ipOrMaskChars) {
            int a;
            if (ipOrMaskChar == '.') {
                number = (number << 8) | temp;
                temp = 0;
                flag++;
            } else if ((a = ipOrMaskChar - '0') >= 0 && a <= 9) {
                temp = temp * 10 + a;
                flag = 0;
            } else {
                return -1;
            }
            if (flag >= 2) {
                return -1;
            }
        }
        return number;
    }
}
